
var Ajax_method='text';
var Ajax_container='';
var Ajax_query_loading=false;
var Ajax_extent_eval='';

function Ajax_object()
{
	this.create=null;
	this.ajaxdisabled="ERROR: Ajax disabled . \nREASON: Browser can not run ajax project .\n-----------------------------------------\nHELP: http://www.wesofts.com\n-----------------------------------------\t\n";
	this.request=function()
	{
		if(window.XMLHttpRequest)
		{
			this.create=new XMLHttpRequest();
			
			if(this.create.overrideMimeType)
			{
				this.create.overrideMimeType('text/xml');
			}
		}
		else if(window.ActiveXObject)
		{
			var versions=['Microsoft.XMLHTTP','MSXML.XMLHTTP','Microsoft.XMLHTTP','Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP'];
			
			for(var i=0;i<versions.length;i++)
			{
				try
				{
					this.create=new ActiveXObject(versions[i]);
					
					if(this.create)
					{
						return this.create;
					}
				}
				catch(e){}
			}
		}
	}
	
	this.get=function(action,option,extent,eid)
	{
		if(this.create==null)
		{
			alert(this.ajaxdisabled);
			return false;
		}
	
		Ajax_method='text';
		Ajax_container=eid?eid:'';
		this.targeturl=Ajax_targeturl(action,option,extent);

		if(window.XMLHttpRequest)
		{
			Ajax.create.open('GET',this.targeturl);
			Ajax.create.send(null);
		}
		else
		{
			Ajax.create.open("GET",this.targeturl,true);
			Ajax.create.send();
		}
	
		Ajax.create.onreadystatechange=this.process;
	}

	this.post=function(action,option,extent,eid,data)
	{
		if(this.create==null)
		{
			alert(this.ajaxdisabled);
			return false;
		}
		
		Ajax_method='text';
		Ajax_container=eid?eid:'';
		var Ajax_postdat=data&&data!=''?data:'';
		this.targeturl=Ajax_targeturl(action,option,extent);
		Ajax.create.open('POST',this.targeturl);
		Ajax.create.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		Ajax.create.send(Ajax_postdat);
		Ajax.create.onreadystatechange=this.process;
	}

	this.xml=function(url,eid,exteval)
	{
		Ajax_query_loading=true;
		if(this.create==null)
		{
			alert(this.ajaxdisabled);
			return false;
		}

		Ajax_method='xml';
		Ajax_container=eid?eid:'';
		
		if(exteval&&exteval!='')
		{
			Ajax_extent_eval=exteval;
		}
		else
		{
			Ajax_extent_eval='';
		}

		this.targeturl=Ajax_targeturl(url);
		
		if(window.XMLHttpRequest)
		{
			Ajax.create.open('GET',this.targeturl);
			Ajax.create.send(null);
		}
		else
		{
			Ajax.create.open("GET",this.targeturl,true);
			Ajax.create.send();
		}

		Ajax.create.onreadystatechange=this.process;
	}

	this.process=function()
	{
		if(Ajax.create.readyState==4)
		{
			if(Ajax.create.status==200)
			{
				var responsed=Ajax.create.responseText;
				var querytype='';
				
				switch(responsed.substr(2,3))
				{
					case'xml':querytype='xml';break;
					case'tml':querytype='tml';break;
					default:break;
				}

				if(querytype=='xml')
				{
					Ajax_parse(Ajax.create.responseXML.lastChild.firstChild.nodeValue);
					Ajax_query_loading=false;
				}
				else
				{
					if(querytype=='tml'&&Ajax_method=='xml')
					{
						eval(responsed.replace(/<[a-z\/]+>/g,''));
						Ajax_query_loading=false;
					}
					else
					{
						Ajax_parse(responsed);
						Ajax_query_loading=false;
					}
		
					return false;
				}
			}
			else
			{
				Ajax_parse('<b>Fail</b>: HTTP 404 NOT FOUND. ');
				Ajax_query_loading=false;
			}

			Ajax_container='';
		}
	}
}

function Ajax_targeturl(url)
{
	var urls='ajax.jsp?used=0';

	if(typeof Ajax_prefix!='undefined')
	{
		urls=Ajax_prefix+urls;
	}

	urls+=url?'&action='+url.replace(/&amp;/g,'&'):'';

	return urls;
}

//function Ajax_targeturl(url)
//{
//	return './xml/' + url + '.jsp';
//}

function Ajax_parse(contain)
{
	if(!$_(Ajax_container)&&contain!='')
	{
		return false;
	}

	$_(Ajax_container).innerHTML=contain;
	if(Ajax_extent_eval!='')
	{
		eval(Ajax_extent_eval);
	}
}

Ajax=new Ajax_object();
if(typeof Ajax=='object')
{
	Ajax.request();
}

function jsloader()
{
	this.loader=function()
	{
		for(var i=0;i<this.args.length;i++)
		{
			if(typeof this.args[i][1]!='undefined')
			{
				this.wrap[this.nume]=[this.args[i][0],this.args[i][1]];this.nume++;
			}
		}
		if(this.nume>0)
		{
			JSloader_parser();
		}
	}
}

JSloader=new jsloader();

if(typeof JSloader=='object')
{
	JSloader.nums=0;
	JSloader.nume=0;
	JSloader.args=new Array();
	JSloader.wrap=new Array();
}

function JSloader_parser()
{
	if(typeof JSloader!='object'||JSloader.nume<=0||JSloader.nums>=JSloader.nume)
	{
		return false;
	}
	else
	{
		if(!Ajax.Ajax_query_loading)
		{
			if($_(JSloader.wrap[JSloader.nums][1]))
			{
				Ajax.xml(JSloader.wrap[JSloader.nums][0],JSloader.wrap[JSloader.nums][1]);
			}
			JSloader.nums++;
		}
		setTimeout('JSloader_parser()',500);
	}
}
